//
//  WPMineThirdBtn.m
//  wobingwoyi
//
//  Created by WGP on 16/7/27.
//  Copyright © 2016年 WGP. All rights reserved.
//

#import "WPMineThirdBtn.h"

@implementation WPMineThirdBtn

+(instancetype)mineBtnWith:(NSString *)imageName title:(NSString *)title mineBtnType:(WPMineBtnTypes)btnType
{
    WPMineThirdBtn *btn = [WPMineThirdBtn buttonWithType:UIButtonTypeCustom];
    btn.backgroundColor = [UIColor whiteColor];
    btn.titleLabel.font = [UIFont systemFontOfSize:15.4];
    [btn setTitleColor:RGB_SAME(51) forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [btn setTitle:title forState:UIControlStateNormal];
    [btn.titleLabel sizeToFit];
    btn.btnType = btnType;
    
    return btn;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    CGFloat imageW = 25*SCALE;
    CGFloat imageH = imageW;
    CGFloat imageX = 15*SCALE;
    CGFloat imageY = (self.bounds.size.height-imageH)*0.5;
    
    self.imageView.frame = CGRectMake(imageX, imageY, imageW, imageH);
    
    CGFloat titleLabelW = self.titleLabel.bounds.size.width;
    CGFloat titleLabelH = self.titleLabel.bounds.size.height;
     CGFloat titleLabelY = (self.bounds.size.height-titleLabelH)*0.5;
    
    self.titleLabel.frame = CGRectMake(CGRectGetMaxX(self.imageView.frame)+ 10*SCALE, titleLabelY, titleLabelW, titleLabelH);
}

@end
